package cn.shujuhai.cms.controller.info;

import cn.shujuhai.cms.aop.Count;
import cn.shujuhai.cms.service.thymeleaf.InfoService;
import cn.shujuhai.common.aop.SysLog;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: zhangDeZhong
 * @Date: 2024/12/5 12:01
 * @Description: 提供文章模板访问接口
 **/
@RestController
@RequestMapping("/cms/info")
@RequiredArgsConstructor
public class InfoController {

    private final InfoService infoService;

    /**
     * 根据栏目的url和文章ID渲染相应的模板
     *
     * @param url       栏目路径
     * @param articleId 文章ID
     * @return 渲染后的模板内容
     */
    @Count(value = "计算文章浏览量", module = "info")
    @SysLog(value = "访问文章信息模板页面", operationType = "浏览", module = "前台模块")
    @GetMapping("/{url}/{articleId}")
    public String getInfo(@PathVariable String url, @PathVariable Long articleId) {
        return this.infoService.getInfo(url, articleId);
    }
}
